package fuck.hookwzry.qq;

import java.security.SecureRandom;
import java.util.Random;

public class util {

    public static final int E_TLV_VERIFY = -1005;
    public static final int E_TLV_DECRYPT = -1015;

    public static void LOGI(String a,String b){
    }

    public static void int16_to_buf(byte[] bArr, int i, int i2) {
        bArr[i + 1] = (byte) (i2 >> 0);
        bArr[i + 0] = (byte) (i2 >> 8);
    }

    public static int buf_to_int16(byte[] bArr, int i) {
        return ((bArr[i] << 8) & 65280) + ((bArr[i + 1] << 0) & 255);
    }

    public static byte[] string_to_buf(String str) {
        if (str == null) {
            return new byte[0];
        }
        byte[] bArr = new byte[(str.length() / 2)];
        for (int i = 0; i < str.length() / 2; i++) {
            int i2 = i * 2;
            bArr[i] = (byte) ((get_char((byte) str.charAt(i2)) << 4) + get_char((byte) str.charAt(i2 + 1)));
        }
        return bArr;
    }

    public static byte get_char(byte b) {
        int i;
        if (b < 48 || b > 57) {
            byte b2 = 97;
            if (b < 97 || b > 102) {
                b2 = 65;
                if (b < 65 || b > 70) {
                    return 0;
                }
            }
            i = (b - b2) + 10;
        } else {
            i = b - 48;
        }
        return (byte) i;
    }

    public static void int8_to_buf(byte[] bArr, int i, int i2) {
        bArr[i + 0] = (byte) (i2 >> 0);
    }

    public static void int32_to_buf(byte[] bArr, int i, int i2) {
        bArr[i + 3] = (byte) (i2);
        bArr[i + 2] = (byte) (i2 >> 8);
        bArr[i + 1] = (byte) (i2 >> 16);
        bArr[i] = (byte) (i2 >> 24);
    }
    public static long buf_to_int64(byte[] bArr, int i) {
        return ((((long) bArr[i]) << 56) & -72057594037927936L) + ((((long) bArr[i + 1]) << 48) & 71776119061217280L) + ((((long) bArr[i + 2]) << 40) & 280375465082880L) + ((((long) bArr[i + 3]) << 32) & 1095216660480L) + ((((long) bArr[i + 4]) << 24) & 4278190080L) + ((((long) bArr[i + 5]) << 16) & 16711680) + ((((long) bArr[i + 6]) << 8) & 65280) + ((((long) bArr[i + 7]) << 0) & 255);
    }
    public static void int64_to_buf(byte[] bArr, int i, long j) {
        bArr[i + 7] = (byte) ((int) (j));
        bArr[i + 6] = (byte) ((int) (j >> 8));
        bArr[i + 5] = (byte) ((int) (j >> 16));
        bArr[i + 4] = (byte) ((int) (j >> 24));
        bArr[i + 3] = (byte) ((int) (j >> 32));
        bArr[i + 2] = (byte) ((int) (j >> 40));
        bArr[i + 1] = (byte) ((int) (j >> 48));
        bArr[i] = (byte) ((int) (j >> 56));
    }

    public static int get_rand_32() {
        return ((int)(Math.random() * 2147483647));
    }

    public static long get_server_cur_time() {
        return System.currentTimeMillis() / 1000;
    }

    public static void int64_to_buf32(byte[] arg4, int arg5, long arg6) {
        arg4[arg5 + 3] = ((byte)(((int)(arg6))));
        arg4[arg5 + 2] = ((byte)(((int)(arg6 >> 8))));
        arg4[arg5 + 1] = ((byte)(((int)(arg6 >> 16))));
        arg4[arg5] = ((byte)(((int)(arg6 >> 24))));
    }

    public static long constructSalt() {
        return ((((long) util.get_rand_32())) << 0x20) + (((long) util.get_rand_32()));
    }

    public static String get_mpasswd() {
        StringBuilder v1;
        int v0 = 16;
        try {
            byte[] v0_1 = SecureRandom.getSeed(v0);
            v1 = new StringBuilder();
            int v2;
            for(v2 = 0; v2 < v0_1.length; ++v2) {
                boolean v3 = new Random().nextBoolean();
                int v4 = Math.abs(v0_1[v2] % 26);
                int v3_1 = v3 ? 97 : 65;
                v4 += v3_1;
                v1.append(String.valueOf(((char) v4)));
            }
        }
        catch(Throwable e) {
            return "1234567890123456";
        }

        return v1.toString();
    }

    public static String buf_to_string(byte[] arg3) {
        String v0 = "";
        if(arg3 == null) {
            return v0;
        }

        int v1;
        for(v1 = 0; v1 < arg3.length; ++v1) {
            v0 = v0 + Integer.toHexString(arg3[v1] >> 4 & 15);
            v0 = v0 + Integer.toHexString(arg3[v1] & 15);
        }

        return v0;
    }

    public static String buf_to_string(byte[] arg3, int arg4) {
        String v0 = "";
        if(arg3 == null) {
            return v0;
        }

        if(arg4 > arg3.length) {
            arg4 = arg3.length;
        }

        int v1;
        for(v1 = 0; v1 < arg4; ++v1) {
            v0 = v0 + Integer.toHexString(arg3[v1] >> 4 & 15);
            v0 = v0 + Integer.toHexString(arg3[v1] & 15);
        }

        return v0;
    }

    public static int buf_to_int32(byte[] arg3, int arg4) {
        return (arg3[arg4] << 24 & 0xFF000000) + (arg3[arg4 + 1] << 16 & 0xFF0000) + (arg3[arg4 + 2] << 8 & 0xFF00) + (arg3[arg4 + 3] << 0 & 0xFF);
    }

}
